package org.goldfish.distributed_framework.registry;


import java.util.*;

public class ServiceRegistry {
    private static final Map<String, Set<String>> registry = new HashMap<>();

    public static synchronized void register(String serviceName, String address) {
        registry.computeIfAbsent(serviceName, k -> new HashSet<>()).add(address);
    }

    public static synchronized Set<String> query(String serviceName) {
        return registry.getOrDefault(serviceName, Collections.emptySet());
    }

    public static synchronized void clear() {
        registry.clear();
    }
}
